/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.senai.service;

import br.senai.entity.Categoria;
import br.senai.helper.HibernateHelper;
import br.senai.interfaces.Action;
import java.util.List;

/**
 *
 * @author Fernando
 */
public class CategoriaService implements Action {
    
    
    public CategoriaService (){
        
    }
    
     @Override
    public Boolean save(Object obj) {
        if (obj != null) {
            return HibernateHelper.saveOrUpdate(obj);
        } else {
            return false;
        }
    }

    @Override
    public Boolean delete(Object obj) {
        if (obj != null) {
            return HibernateHelper.delete(obj);
        } else {
            return false;
        }
    }


    @Override
    public List<Object> getList(String hql) {
         if (hql != null) {
            return HibernateHelper.execHQL(hql);
        } else {
            return null;
        }             
    }

    @Override
    public Object getById(Object obj) {
         if (obj != null) {
             Categoria categoria = (Categoria) obj;
            return HibernateHelper.getById(Object.class, categoria.getIdCategoria());
        } else {
            return null;
        }   
    }        
}
